﻿Imports System.Data.SqlClient
Imports MySql.Data.MySqlClient

Public Class frmMaHoaNhanVien
    Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents btnNew As System.Windows.Forms.Button
    Friend WithEvents btnSave As System.Windows.Forms.Button
    Friend WithEvents btnDelete1 As System.Windows.Forms.Button
    Friend WithEvents txtMaNhanVien As System.Windows.Forms.TextBox
    Friend WithEvents BtnClose As System.Windows.Forms.Button
    Friend WithEvents BtnIn As System.Windows.Forms.Button
    Friend WithEvents Label5 As System.Windows.Forms.Label
    Friend WithEvents DataGridView1 As System.Windows.Forms.DataGridView
    Friend WithEvents CboHocVi As MTGCComboBox
    Friend WithEvents GhichuDataGridViewTextBoxColumn As System.Windows.Forms.DataGridViewTextBoxColumn
    Friend WithEvents MatinhDataGridViewTextBoxColumn As System.Windows.Forms.DataGridViewTextBoxColumn
    Friend WithEvents CboNganhNghe As MTGCComboBox
    Friend WithEvents TxtTenNganhNghe As System.Windows.Forms.TextBox
    Friend WithEvents Label6 As System.Windows.Forms.Label
    Friend WithEvents TxtKyHieu As System.Windows.Forms.TextBox
    Friend WithEvents DataSetForm_Sop As PHUQUI.DataSetForm_Sop
    Friend WithEvents Label3 As System.Windows.Forms.Label
    Friend WithEvents OptNam As System.Windows.Forms.RadioButton
    Friend WithEvents OptNu As System.Windows.Forms.RadioButton
    Friend WithEvents CboTenNhanVien As MTGCComboBox
    Friend WithEvents TxtTenNhanVien As System.Windows.Forms.TextBox
    Friend WithEvents Label4 As System.Windows.Forms.Label
    Friend WithEvents TblmahoanhanvienBindingSource As System.Windows.Forms.BindingSource
    Friend WithEvents txtCapNhatThanh As System.Windows.Forms.TextBox
    Friend WithEvents Label7 As System.Windows.Forms.Label
    Friend WithEvents ManhanvienDataGridViewTextBoxColumn As System.Windows.Forms.DataGridViewTextBoxColumn
    Friend WithEvents GioitinhDataGridViewTextBoxColumn As System.Windows.Forms.DataGridViewTextBoxColumn
    Friend WithEvents TennhanvienDataGridViewTextBoxColumn As System.Windows.Forms.DataGridViewTextBoxColumn
    Friend WithEvents LoaihocviDataGridViewTextBoxColumn As System.Windows.Forms.DataGridViewTextBoxColumn
    Friend WithEvents LoainganhngheDataGridViewTextBoxColumn As System.Windows.Forms.DataGridViewTextBoxColumn
    Friend WithEvents TxtTenHocVi As System.Windows.Forms.TextBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container
        Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(frmMaHoaNhanVien))
        Dim DataGridViewCellStyle2 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle
        Me.btnSave = New System.Windows.Forms.Button
        Me.txtMaNhanVien = New System.Windows.Forms.TextBox
        Me.Label2 = New System.Windows.Forms.Label
        Me.Label1 = New System.Windows.Forms.Label
        Me.btnNew = New System.Windows.Forms.Button
        Me.btnDelete1 = New System.Windows.Forms.Button
        Me.BtnClose = New System.Windows.Forms.Button
        Me.BtnIn = New System.Windows.Forms.Button
        Me.Label5 = New System.Windows.Forms.Label
        Me.TxtTenHocVi = New System.Windows.Forms.TextBox
        Me.DataGridView1 = New System.Windows.Forms.DataGridView
        Me.ManhanvienDataGridViewTextBoxColumn = New System.Windows.Forms.DataGridViewTextBoxColumn
        Me.GioitinhDataGridViewTextBoxColumn = New System.Windows.Forms.DataGridViewTextBoxColumn
        Me.TennhanvienDataGridViewTextBoxColumn = New System.Windows.Forms.DataGridViewTextBoxColumn
        Me.LoaihocviDataGridViewTextBoxColumn = New System.Windows.Forms.DataGridViewTextBoxColumn
        Me.LoainganhngheDataGridViewTextBoxColumn = New System.Windows.Forms.DataGridViewTextBoxColumn
        Me.TblmahoanhanvienBindingSource = New System.Windows.Forms.BindingSource(Me.components)
        Me.DataSetForm_Sop = New PHUQUI.DataSetForm_Sop
        Me.CboHocVi = New MTGCComboBox
        Me.CboNganhNghe = New MTGCComboBox
        Me.TxtTenNganhNghe = New System.Windows.Forms.TextBox
        Me.Label6 = New System.Windows.Forms.Label
        Me.TxtKyHieu = New System.Windows.Forms.TextBox
        Me.Label3 = New System.Windows.Forms.Label
        Me.OptNam = New System.Windows.Forms.RadioButton
        Me.OptNu = New System.Windows.Forms.RadioButton
        Me.CboTenNhanVien = New MTGCComboBox
        Me.TxtTenNhanVien = New System.Windows.Forms.TextBox
        Me.Label4 = New System.Windows.Forms.Label
        Me.txtCapNhatThanh = New System.Windows.Forms.TextBox
        Me.Label7 = New System.Windows.Forms.Label
        CType(Me.DataGridView1, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.TblmahoanhanvienBindingSource, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.DataSetForm_Sop, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'btnSave
        '
        Me.btnSave.BackColor = System.Drawing.Color.Transparent
        Me.btnSave.Image = CType(resources.GetObject("btnSave.Image"), System.Drawing.Image)
        Me.btnSave.Location = New System.Drawing.Point(252, 170)
        Me.btnSave.Name = "btnSave"
        Me.btnSave.Size = New System.Drawing.Size(88, 24)
        Me.btnSave.TabIndex = 5
        Me.btnSave.UseVisualStyleBackColor = False
        '
        'txtMaNhanVien
        '
        Me.txtMaNhanVien.BackColor = System.Drawing.SystemColors.Info
        Me.txtMaNhanVien.Font = New System.Drawing.Font("Arial", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.txtMaNhanVien.ForeColor = System.Drawing.Color.Red
        Me.txtMaNhanVien.Location = New System.Drawing.Point(326, 45)
        Me.txtMaNhanVien.MaxLength = 10
        Me.txtMaNhanVien.Name = "txtMaNhanVien"
        Me.txtMaNhanVien.Size = New System.Drawing.Size(123, 26)
        Me.txtMaNhanVien.TabIndex = 1
        Me.txtMaNhanVien.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
        '
        'Label2
        '
        Me.Label2.Location = New System.Drawing.Point(98, 46)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(96, 18)
        Me.Label2.TabIndex = 12
        Me.Label2.Text = "Ký hiệu Danh Mục"
        Me.Label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'Label1
        '
        Me.Label1.BackColor = System.Drawing.Color.Transparent
        Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 15.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label1.Location = New System.Drawing.Point(228, 4)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(422, 24)
        Me.Label1.TabIndex = 11
        Me.Label1.Text = "MÃ HÓA DANH MỤC NHÂN VIÊN"
        '
        'btnNew
        '
        Me.btnNew.Image = CType(resources.GetObject("btnNew.Image"), System.Drawing.Image)
        Me.btnNew.Location = New System.Drawing.Point(155, 170)
        Me.btnNew.Name = "btnNew"
        Me.btnNew.Size = New System.Drawing.Size(88, 24)
        Me.btnNew.TabIndex = 6
        '
        'btnDelete1
        '
        Me.btnDelete1.Image = CType(resources.GetObject("btnDelete1.Image"), System.Drawing.Image)
        Me.btnDelete1.Location = New System.Drawing.Point(351, 170)
        Me.btnDelete1.Name = "btnDelete1"
        Me.btnDelete1.Size = New System.Drawing.Size(88, 24)
        Me.btnDelete1.TabIndex = 29
        '
        'BtnClose
        '
        Me.BtnClose.Image = CType(resources.GetObject("BtnClose.Image"), System.Drawing.Image)
        Me.BtnClose.Location = New System.Drawing.Point(549, 170)
        Me.BtnClose.Name = "BtnClose"
        Me.BtnClose.Size = New System.Drawing.Size(88, 24)
        Me.BtnClose.TabIndex = 30
        '
        'BtnIn
        '
        Me.BtnIn.Image = CType(resources.GetObject("BtnIn.Image"), System.Drawing.Image)
        Me.BtnIn.Location = New System.Drawing.Point(450, 170)
        Me.BtnIn.Name = "BtnIn"
        Me.BtnIn.Size = New System.Drawing.Size(88, 24)
        Me.BtnIn.TabIndex = 39
        '
        'Label5
        '
        Me.Label5.Location = New System.Drawing.Point(101, 118)
        Me.Label5.Name = "Label5"
        Me.Label5.Size = New System.Drawing.Size(93, 18)
        Me.Label5.TabIndex = 41
        Me.Label5.Text = "Loại Học Vị"
        Me.Label5.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'TxtTenHocVi
        '
        Me.TxtTenHocVi.Font = New System.Drawing.Font("Arial", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.TxtTenHocVi.Location = New System.Drawing.Point(323, 117)
        Me.TxtTenHocVi.MaxLength = 50
        Me.TxtTenHocVi.Name = "TxtTenHocVi"
        Me.TxtTenHocVi.Size = New System.Drawing.Size(343, 22)
        Me.TxtTenHocVi.TabIndex = 42
        '
        'DataGridView1
        '
        Me.DataGridView1.AllowUserToAddRows = False
        Me.DataGridView1.AllowUserToDeleteRows = False
        Me.DataGridView1.AllowUserToResizeColumns = False
        Me.DataGridView1.AutoGenerateColumns = False
        Me.DataGridView1.BackgroundColor = System.Drawing.Color.LightBlue
        DataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter
        DataGridViewCellStyle2.BackColor = System.Drawing.SystemColors.Control
        DataGridViewCellStyle2.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        DataGridViewCellStyle2.ForeColor = System.Drawing.SystemColors.WindowText
        DataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight
        DataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText
        DataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.[True]
        Me.DataGridView1.ColumnHeadersDefaultCellStyle = DataGridViewCellStyle2
        Me.DataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize
        Me.DataGridView1.Columns.AddRange(New System.Windows.Forms.DataGridViewColumn() {Me.ManhanvienDataGridViewTextBoxColumn, Me.GioitinhDataGridViewTextBoxColumn, Me.TennhanvienDataGridViewTextBoxColumn, Me.LoaihocviDataGridViewTextBoxColumn, Me.LoainganhngheDataGridViewTextBoxColumn})
        Me.DataGridView1.DataSource = Me.TblmahoanhanvienBindingSource
        Me.DataGridView1.Location = New System.Drawing.Point(12, 200)
        Me.DataGridView1.Name = "DataGridView1"
        Me.DataGridView1.ReadOnly = True
        Me.DataGridView1.Size = New System.Drawing.Size(768, 371)
        Me.DataGridView1.TabIndex = 48
        '
        'ManhanvienDataGridViewTextBoxColumn
        '
        Me.ManhanvienDataGridViewTextBoxColumn.DataPropertyName = "manhanvien"
        Me.ManhanvienDataGridViewTextBoxColumn.HeaderText = "Mã số NV"
        Me.ManhanvienDataGridViewTextBoxColumn.Name = "ManhanvienDataGridViewTextBoxColumn"
        Me.ManhanvienDataGridViewTextBoxColumn.ReadOnly = True
        '
        'GioitinhDataGridViewTextBoxColumn
        '
        Me.GioitinhDataGridViewTextBoxColumn.DataPropertyName = "gioitinh"
        Me.GioitinhDataGridViewTextBoxColumn.HeaderText = "Giới tính"
        Me.GioitinhDataGridViewTextBoxColumn.Name = "GioitinhDataGridViewTextBoxColumn"
        Me.GioitinhDataGridViewTextBoxColumn.ReadOnly = True
        '
        'TennhanvienDataGridViewTextBoxColumn
        '
        Me.TennhanvienDataGridViewTextBoxColumn.DataPropertyName = "tennhanvien"
        Me.TennhanvienDataGridViewTextBoxColumn.HeaderText = "Tên NV"
        Me.TennhanvienDataGridViewTextBoxColumn.Name = "TennhanvienDataGridViewTextBoxColumn"
        Me.TennhanvienDataGridViewTextBoxColumn.ReadOnly = True
        Me.TennhanvienDataGridViewTextBoxColumn.Width = 250
        '
        'LoaihocviDataGridViewTextBoxColumn
        '
        Me.LoaihocviDataGridViewTextBoxColumn.DataPropertyName = "loaihocvi"
        Me.LoaihocviDataGridViewTextBoxColumn.HeaderText = "Loại học vị"
        Me.LoaihocviDataGridViewTextBoxColumn.Name = "LoaihocviDataGridViewTextBoxColumn"
        Me.LoaihocviDataGridViewTextBoxColumn.ReadOnly = True
        '
        'LoainganhngheDataGridViewTextBoxColumn
        '
        Me.LoainganhngheDataGridViewTextBoxColumn.DataPropertyName = "loainganhnghe"
        Me.LoainganhngheDataGridViewTextBoxColumn.HeaderText = "Ngành nghề"
        Me.LoainganhngheDataGridViewTextBoxColumn.Name = "LoainganhngheDataGridViewTextBoxColumn"
        Me.LoainganhngheDataGridViewTextBoxColumn.ReadOnly = True
        Me.LoainganhngheDataGridViewTextBoxColumn.Width = 150
        '
        'TblmahoanhanvienBindingSource
        '
        Me.TblmahoanhanvienBindingSource.DataMember = "tbl_mahoanhanvien"
        Me.TblmahoanhanvienBindingSource.DataSource = Me.DataSetForm_Sop
        '
        'DataSetForm_Sop
        '
        Me.DataSetForm_Sop.DataSetName = "DataSetForm_Sop"
        Me.DataSetForm_Sop.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema
        '
        'CboHocVi
        '
        Me.CboHocVi.ArrowBoxColor = System.Drawing.SystemColors.Control
        Me.CboHocVi.ArrowColor = System.Drawing.Color.Black
        Me.CboHocVi.BindedControl = Nothing
        Me.CboHocVi.BorderStyle = MTGCComboBox.TipiBordi.Fixed3D
        Me.CboHocVi.CharacterCasing = System.Windows.Forms.CharacterCasing.Normal
        Me.CboHocVi.ColumnNum = 1
        Me.CboHocVi.ColumnWidth = "121"
        Me.CboHocVi.DisabledArrowBoxColor = System.Drawing.SystemColors.Control
        Me.CboHocVi.DisabledArrowColor = System.Drawing.Color.LightGray
        Me.CboHocVi.DisabledBackColor = System.Drawing.SystemColors.Control
        Me.CboHocVi.DisabledBorderColor = System.Drawing.SystemColors.InactiveBorder
        Me.CboHocVi.DisabledForeColor = System.Drawing.SystemColors.GrayText
        Me.CboHocVi.DisplayMember = "Text"
        Me.CboHocVi.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed
        Me.CboHocVi.DropDownBackColor = System.Drawing.Color.FromArgb(CType(CType(193, Byte), Integer), CType(CType(210, Byte), Integer), CType(CType(238, Byte), Integer))
        Me.CboHocVi.DropDownForeColor = System.Drawing.Color.Black
        Me.CboHocVi.DropDownStyle = MTGCComboBox.CustomDropDownStyle.DropDown
        Me.CboHocVi.DropDownWidth = 141
        Me.CboHocVi.GridLineColor = System.Drawing.Color.LightGray
        Me.CboHocVi.GridLineHorizontal = False
        Me.CboHocVi.GridLineVertical = False
        Me.CboHocVi.LoadingType = MTGCComboBox.CaricamentoCombo.ComboBoxItem
        Me.CboHocVi.Location = New System.Drawing.Point(199, 117)
        Me.CboHocVi.ManagingFastMouseMoving = True
        Me.CboHocVi.ManagingFastMouseMovingInterval = 30
        Me.CboHocVi.Name = "CboHocVi"
        Me.CboHocVi.SelectedItem = Nothing
        Me.CboHocVi.SelectedValue = Nothing
        Me.CboHocVi.Size = New System.Drawing.Size(123, 21)
        Me.CboHocVi.TabIndex = 49
        '
        'CboNganhNghe
        '
        Me.CboNganhNghe.ArrowBoxColor = System.Drawing.SystemColors.Control
        Me.CboNganhNghe.ArrowColor = System.Drawing.Color.Black
        Me.CboNganhNghe.BindedControl = Nothing
        Me.CboNganhNghe.BorderStyle = MTGCComboBox.TipiBordi.Fixed3D
        Me.CboNganhNghe.CharacterCasing = System.Windows.Forms.CharacterCasing.Normal
        Me.CboNganhNghe.ColumnNum = 1
        Me.CboNganhNghe.ColumnWidth = "121"
        Me.CboNganhNghe.DisabledArrowBoxColor = System.Drawing.SystemColors.Control
        Me.CboNganhNghe.DisabledArrowColor = System.Drawing.Color.LightGray
        Me.CboNganhNghe.DisabledBackColor = System.Drawing.SystemColors.Control
        Me.CboNganhNghe.DisabledBorderColor = System.Drawing.SystemColors.InactiveBorder
        Me.CboNganhNghe.DisabledForeColor = System.Drawing.SystemColors.GrayText
        Me.CboNganhNghe.DisplayMember = "Text"
        Me.CboNganhNghe.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed
        Me.CboNganhNghe.DropDownBackColor = System.Drawing.Color.FromArgb(CType(CType(193, Byte), Integer), CType(CType(210, Byte), Integer), CType(CType(238, Byte), Integer))
        Me.CboNganhNghe.DropDownForeColor = System.Drawing.Color.Black
        Me.CboNganhNghe.DropDownStyle = MTGCComboBox.CustomDropDownStyle.DropDown
        Me.CboNganhNghe.DropDownWidth = 141
        Me.CboNganhNghe.GridLineColor = System.Drawing.Color.LightGray
        Me.CboNganhNghe.GridLineHorizontal = False
        Me.CboNganhNghe.GridLineVertical = False
        Me.CboNganhNghe.LoadingType = MTGCComboBox.CaricamentoCombo.ComboBoxItem
        Me.CboNganhNghe.Location = New System.Drawing.Point(199, 142)
        Me.CboNganhNghe.ManagingFastMouseMoving = True
        Me.CboNganhNghe.ManagingFastMouseMovingInterval = 30
        Me.CboNganhNghe.Name = "CboNganhNghe"
        Me.CboNganhNghe.SelectedItem = Nothing
        Me.CboNganhNghe.SelectedValue = Nothing
        Me.CboNganhNghe.Size = New System.Drawing.Size(123, 21)
        Me.CboNganhNghe.TabIndex = 52
        '
        'TxtTenNganhNghe
        '
        Me.TxtTenNganhNghe.Font = New System.Drawing.Font("Arial", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.TxtTenNganhNghe.Location = New System.Drawing.Point(323, 142)
        Me.TxtTenNganhNghe.MaxLength = 50
        Me.TxtTenNganhNghe.Name = "TxtTenNganhNghe"
        Me.TxtTenNganhNghe.Size = New System.Drawing.Size(343, 22)
        Me.TxtTenNganhNghe.TabIndex = 51
        '
        'Label6
        '
        Me.Label6.Location = New System.Drawing.Point(102, 142)
        Me.Label6.Name = "Label6"
        Me.Label6.Size = New System.Drawing.Size(92, 18)
        Me.Label6.TabIndex = 50
        Me.Label6.Text = "Loại Ngành Nghề"
        Me.Label6.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'TxtKyHieu
        '
        Me.TxtKyHieu.BackColor = System.Drawing.SystemColors.Window
        Me.TxtKyHieu.Font = New System.Drawing.Font("Arial", 11.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.TxtKyHieu.Location = New System.Drawing.Point(199, 45)
        Me.TxtKyHieu.MaxLength = 10
        Me.TxtKyHieu.Name = "TxtKyHieu"
        Me.TxtKyHieu.Size = New System.Drawing.Size(123, 25)
        Me.TxtKyHieu.TabIndex = 56
        Me.TxtKyHieu.Text = "M"
        Me.TxtKyHieu.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
        '
        'Label3
        '
        Me.Label3.Location = New System.Drawing.Point(90, 70)
        Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(104, 18)
        Me.Label3.TabIndex = 57
        Me.Label3.Text = "Giới Tính Nhân Viên"
        Me.Label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'OptNam
        '
        Me.OptNam.AutoSize = True
        Me.OptNam.Location = New System.Drawing.Point(215, 73)
        Me.OptNam.Name = "OptNam"
        Me.OptNam.Size = New System.Drawing.Size(47, 17)
        Me.OptNam.TabIndex = 58
        Me.OptNam.TabStop = True
        Me.OptNam.Text = "Nam"
        Me.OptNam.UseVisualStyleBackColor = True
        '
        'OptNu
        '
        Me.OptNu.AutoSize = True
        Me.OptNu.Location = New System.Drawing.Point(272, 73)
        Me.OptNu.Name = "OptNu"
        Me.OptNu.Size = New System.Drawing.Size(39, 17)
        Me.OptNu.TabIndex = 59
        Me.OptNu.TabStop = True
        Me.OptNu.Text = "Nữ"
        Me.OptNu.UseVisualStyleBackColor = True
        '
        'CboTenNhanVien
        '
        Me.CboTenNhanVien.ArrowBoxColor = System.Drawing.SystemColors.Control
        Me.CboTenNhanVien.ArrowColor = System.Drawing.Color.Black
        Me.CboTenNhanVien.BindedControl = Nothing
        Me.CboTenNhanVien.BorderStyle = MTGCComboBox.TipiBordi.Fixed3D
        Me.CboTenNhanVien.CharacterCasing = System.Windows.Forms.CharacterCasing.Normal
        Me.CboTenNhanVien.ColumnNum = 1
        Me.CboTenNhanVien.ColumnWidth = "121"
        Me.CboTenNhanVien.DisabledArrowBoxColor = System.Drawing.SystemColors.Control
        Me.CboTenNhanVien.DisabledArrowColor = System.Drawing.Color.LightGray
        Me.CboTenNhanVien.DisabledBackColor = System.Drawing.SystemColors.Control
        Me.CboTenNhanVien.DisabledBorderColor = System.Drawing.SystemColors.InactiveBorder
        Me.CboTenNhanVien.DisabledForeColor = System.Drawing.SystemColors.GrayText
        Me.CboTenNhanVien.DisplayMember = "Text"
        Me.CboTenNhanVien.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed
        Me.CboTenNhanVien.DropDownBackColor = System.Drawing.Color.FromArgb(CType(CType(193, Byte), Integer), CType(CType(210, Byte), Integer), CType(CType(238, Byte), Integer))
        Me.CboTenNhanVien.DropDownForeColor = System.Drawing.Color.Black
        Me.CboTenNhanVien.DropDownStyle = MTGCComboBox.CustomDropDownStyle.DropDown
        Me.CboTenNhanVien.DropDownWidth = 141
        Me.CboTenNhanVien.GridLineColor = System.Drawing.Color.LightGray
        Me.CboTenNhanVien.GridLineHorizontal = False
        Me.CboTenNhanVien.GridLineVertical = False
        Me.CboTenNhanVien.LoadingType = MTGCComboBox.CaricamentoCombo.ComboBoxItem
        Me.CboTenNhanVien.Location = New System.Drawing.Point(199, 92)
        Me.CboTenNhanVien.ManagingFastMouseMoving = True
        Me.CboTenNhanVien.ManagingFastMouseMovingInterval = 30
        Me.CboTenNhanVien.Name = "CboTenNhanVien"
        Me.CboTenNhanVien.SelectedItem = Nothing
        Me.CboTenNhanVien.SelectedValue = Nothing
        Me.CboTenNhanVien.Size = New System.Drawing.Size(123, 21)
        Me.CboTenNhanVien.TabIndex = 62
        '
        'TxtTenNhanVien
        '
        Me.TxtTenNhanVien.Font = New System.Drawing.Font("Arial", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.TxtTenNhanVien.Location = New System.Drawing.Point(323, 92)
        Me.TxtTenNhanVien.MaxLength = 50
        Me.TxtTenNhanVien.Name = "TxtTenNhanVien"
        Me.TxtTenNhanVien.Size = New System.Drawing.Size(343, 22)
        Me.TxtTenNhanVien.TabIndex = 61
        '
        'Label4
        '
        Me.Label4.Location = New System.Drawing.Point(101, 93)
        Me.Label4.Name = "Label4"
        Me.Label4.Size = New System.Drawing.Size(93, 18)
        Me.Label4.TabIndex = 60
        Me.Label4.Text = "Tên Nhân Viên"
        Me.Label4.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'txtCapNhatThanh
        '
        Me.txtCapNhatThanh.BackColor = System.Drawing.SystemColors.Info
        Me.txtCapNhatThanh.Font = New System.Drawing.Font("Arial", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.txtCapNhatThanh.ForeColor = System.Drawing.Color.Red
        Me.txtCapNhatThanh.Location = New System.Drawing.Point(543, 45)
        Me.txtCapNhatThanh.MaxLength = 10
        Me.txtCapNhatThanh.Name = "txtCapNhatThanh"
        Me.txtCapNhatThanh.Size = New System.Drawing.Size(123, 26)
        Me.txtCapNhatThanh.TabIndex = 63
        Me.txtCapNhatThanh.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
        '
        'Label7
        '
        Me.Label7.Location = New System.Drawing.Point(451, 46)
        Me.Label7.Name = "Label7"
        Me.Label7.Size = New System.Drawing.Size(90, 18)
        Me.Label7.TabIndex = 64
        Me.Label7.Text = "Cập nhật thành"
        Me.Label7.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
        '
        'frmMaHoaNhanVien
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.BackColor = System.Drawing.Color.LightBlue
        Me.ClientSize = New System.Drawing.Size(792, 573)
        Me.Controls.Add(Me.Label7)
        Me.Controls.Add(Me.txtCapNhatThanh)
        Me.Controls.Add(Me.CboTenNhanVien)
        Me.Controls.Add(Me.TxtTenNhanVien)
        Me.Controls.Add(Me.Label4)
        Me.Controls.Add(Me.OptNu)
        Me.Controls.Add(Me.OptNam)
        Me.Controls.Add(Me.Label3)
        Me.Controls.Add(Me.TxtKyHieu)
        Me.Controls.Add(Me.CboNganhNghe)
        Me.Controls.Add(Me.TxtTenNganhNghe)
        Me.Controls.Add(Me.Label6)
        Me.Controls.Add(Me.CboHocVi)
        Me.Controls.Add(Me.DataGridView1)
        Me.Controls.Add(Me.TxtTenHocVi)
        Me.Controls.Add(Me.Label5)
        Me.Controls.Add(Me.BtnIn)
        Me.Controls.Add(Me.BtnClose)
        Me.Controls.Add(Me.txtMaNhanVien)
        Me.Controls.Add(Me.btnDelete1)
        Me.Controls.Add(Me.btnNew)
        Me.Controls.Add(Me.btnSave)
        Me.Controls.Add(Me.Label2)
        Me.Controls.Add(Me.Label1)
        Me.Name = "frmMaHoaNhanVien"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = " Ma Hoa Danh Muc Nhan Vien"
        CType(Me.DataGridView1, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.TblmahoanhanvienBindingSource, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.DataSetForm_Sop, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)
        Me.PerformLayout()

    End Sub

#End Region
    Private data1, data2, data3 As DataTable
    Private da As MySqlDataAdapter
    Dim sqlQuery As String = ""
    Dim data As DataTable
    Dim myDT As New DataTable
    Dim strError As String = ""
    Dim myform As Form
    Dim biengt As String = ""

    Dim stateTaoMoi As Boolean = False
    Dim stateCapNhatThanh As Boolean = False
    Private Sub loadMa(ByVal ma As String)
        If ma.Substring(1, 1) = "F" Then
            Me.OptNu.Checked = True
        Else
            Me.OptNam.Checked = True
        End If
        Dim TenNhanVien As String = ma.Substring(2, 3)
        Dim HocVi As String = ma.Substring(5, 1)
        Dim NganhNghe As String = ma.Substring(6, 1)

        For i As Integer = 0 To Me.data2.Rows.Count - 1
            If TenNhanVien = Me.data2.Rows.Item(i).Item(0) Then
                Me.CboTenNhanVien.SelectedIndex = i
                Exit For
            End If
        Next

        For j As Integer = 0 To Me.data1.Rows.Count - 1
            If HocVi = Me.data1.Rows.Item(j).Item(0) Then
                Me.CboHocVi.SelectedIndex = j
                Exit For
            End If
        Next

        For k As Integer = 0 To Me.data3.Rows.Count - 1
            If NganhNghe = Me.data3.Rows.Item(k).Item(0) Then
                Me.CboNganhNghe.SelectedIndex = k
                Exit For
            End If
        Next
    End Sub
    Sub SetclearData()
        txtMaNhanVien.Text = ""
        CboHocVi.Text = ""
        CboNganhNghe.Text = ""
        CboTenNhanVien.Text = ""
        TxtTenNhanVien.Text = ""
        TxtTenHocVi.Text = ""
        TxtTenNganhNghe.Text = ""

    End Sub
    Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
        ' Kiểm tra có nhập liệu chưa ?
        ' If Me.checkInput(txtMa_QUAN.Text, txtTen_QUAN.Text) Then
        Dim txtMaQuan = Me.txtMaNhanVien.Text.Trim
        sqlQuery = "SELECT manhanvien FROM tbl_mahoanhanvien WHERE manhanvien = '" & txtMaQuan & "'"
        Dim existedMamon As Integer = moduleDatabaseConn.CheckRecordExisted(sqlQuery)
        If existedMamon = 1 Then
            moduleConstants.MessageWarning = "Mã  " & Me.txtMaNhanVien.Text & " đã có , bạn muốn cập nhật không ?"
            If MessageBox.Show(moduleConstants.MessageWarning, globalVariale.msgTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) = MsgBoxResult.Yes Then
                If checkInput() = True Then ' Update record
                    sqlQuery = "INSERT INTO tbl_mahoanhanvien "
                    sqlQuery += "(manhanvien , gioitinh,tennhanvien,loaihocvi,loainganhnghe) "
                    sqlQuery += "VALUES "
                    sqlQuery += "("
                    sqlQuery += "'" & txtCapNhatThanh.Text.ToUpper & "', "

                    If Me.OptNam.Checked = True Then
                        biengt = "Nam"
                    Else
                        biengt = "Nữ"
                    End If
                    sqlQuery += "'" & biengt & "', "
                    sqlQuery += "'" & Me.CboTenNhanVien.SelectedItem.Col2 & "', "
                    sqlQuery += "'" & Me.CboHocVi.SelectedItem.Col2 & "', "
                    sqlQuery += "'" & Me.CboNganhNghe.SelectedItem.Col2 & "'"
                    sqlQuery += ")"
                    Dim inserted As Integer = moduleDatabaseConn.ExecuteNonQuery(sqlQuery)
                    '**************delete exist ma~********************
                    sqlQuery = "DELETE FROM tbl_mahoanhanvien WHERE manhanvien = '" & txtMaNhanVien.Text & "'"
                    Dim deleting As Integer = moduleDatabaseConn.ExecuteNonQuery(sqlQuery)
                    If deleting = 1 Then
                        Me.stateCapNhatThanh = False
                        MessageBox.Show("Cập nhật thông tin thành công !")
                        sqlQuery = "SELECT * FROM tbl_mahoanhanvien"
                        Me.loadDanhSachMaHoaNhanVien(sqlQuery)
                    Else
                        MessageBox.Show("Cập nhật thông tin không thành công: " & globalVariale.sqlMsgError)
                    End If
                End If
            End If
        Else
            If existedMamon = 0 And checkInput() = True Then ' Insert record
                sqlQuery = "INSERT INTO tbl_mahoanhanvien "
                sqlQuery += "(manhanvien , gioitinh,tennhanvien,loaihocvi,loainganhnghe) "
                sqlQuery += "VALUES "
                sqlQuery += "("
                sqlQuery += "'" & txtMaQuan.ToUpper & "', "
                If Me.OptNam.Checked = True Then
                    biengt = "Nam"
                Else
                    biengt = "Nữ"
                End If
                sqlQuery += "'" & biengt & "', "
                sqlQuery += "'" & Me.CboTenNhanVien.SelectedItem.Col2 & "', "
                sqlQuery += "'" & Me.CboHocVi.SelectedItem.Col2 & "', "
                sqlQuery += "'" & Me.CboNganhNghe.SelectedItem.Col2 & "'"
                sqlQuery += ")"
                Dim inserted As Integer = moduleDatabaseConn.ExecuteNonQuery(sqlQuery)
                If inserted = 1 Then
                    MessageBox.Show("Thêm thông tin thành công !")
                    sqlQuery = "SELECT * FROM tbl_mahoanhanvien"
                    Me.loadDanhSachMaHoaNhanVien(sqlQuery)
                Else
                    MessageBox.Show("Thêm thông tin không thành công: " & globalVariale.sqlMsgError)
                End If
            Else ' SQLExeption: existedMaQuocGia = -1
                MessageBox.Show("Lấy dữ liệu bị lỗi hoặc chưa click 'Tạo Mới': " & globalVariale.sqlMsgError, "Lấy dữ liệu", MessageBoxButtons.OK, MessageBoxIcon.Warning)
            End If
            Me.stateTaoMoi = False
        End If

    End Sub

    Private Sub btnNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNew.Click
        SetclearData()
        txtMaNhanVien.Focus()

        Me.txtCapNhatThanh.Text = ""
        Me.stateTaoMoi = True
        Me.stateCapNhatThanh = False
    End Sub


    Private Sub btnDelete1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete1.Click
        Dim txtMaQuan As String = Trim(Me.txtMaNhanVien.Text)
        If txtMaQuan = "" Then
            MessageBox.Show("Bạn chưa chọn Mã để xóa !")
        Else
            Dim txtTenQuan As String = Trim(Me.TxtTenNganhNghe.Text)
            moduleConstants.MessageWarning = "Bạn có muốn xóa " & txtMaQuan & "(" & txtTenQuan & ") ?"
            If MessageBox.Show(moduleConstants.MessageWarning, globalVariale.msgTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) = MsgBoxResult.Yes Then
                Dim sqlQuery As String = "DELETE FROM tbl_mahoanhanvien WHERE manhanvien  = '" & txtMaQuan & "'"
                Dim deleting As Integer = moduleDatabaseConn.ExecuteNonQuery(sqlQuery)
                If deleting = 1 Then
                    MessageBox.Show("Xóa thông tin thành công !")
                    sqlQuery = "SELECT * FROM tbl_mahoanhanvien"
                    Me.loadDanhSachMaHoaNhanVien(sqlQuery)
                    SetclearData()
                Else
                    MessageBox.Show("Xóa thông tin không thành công: " & globalVariale.sqlMsgError)
                End If
            End If
        End If
        Me.stateCapNhatThanh = False
        Me.stateTaoMoi = False
    End Sub

    Private Sub FrmMaHoaNhanVien_load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
        moduleUtils.setDinhDangVietNam()
        Me.loadDanhSachMaHoaNhanVien("SELECT manhanvien,gioitinh,tennhanvien,loaihocvi,loainganhnghe FROM tbl_mahoanhanvien")
        Me.loadDanhSachLoaiHocVi()
        Me.loadDanhSachLoaiNganhNghe()
        Me.loadDanhSachTenNhanVien1()
        SetclearData()
        Me.stateCapNhatThanh = False
        Me.stateTaoMoi = True

    End Sub

    Private Sub BtnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnClose.Click
        Me.Close()
    End Sub

    Function checkInput()
        Dim result As Boolean = True
        sqlQuery = "SELECT manhanvien FROM tbl_mahoanhanvien WHERE manhanvien = '" & txtMaNhanVien.Text & "'"
        Dim existedMamon As Integer = moduleDatabaseConn.CheckRecordExisted(sqlQuery)

        If Me.txtMaNhanVien.Text = Me.txtCapNhatThanh.Text Then
            MessageBox.Show(" Không thể cập nhật mã trùng nhau !")
            result = False
        ElseIf Me.txtCapNhatThanh.Text = "" And Me.txtMaNhanVien.Text = "" Then
            MessageBox.Show(" Không thể cập nhật mã rỗng hoặc trùng nhau !")
            result = False
        ElseIf existedMamon = 1 And Me.txtCapNhatThanh.Text = "" Then
            MessageBox.Show(" Không thể cập nhật mã rỗng !")
            result = False
        ElseIf OptNam.Checked = False And OptNu.Checked = False Then
            MessageBox.Show(" Bạn phải chọn giới tính nhân viên !")
            OptNam.Focus()
            result = False
        End If
        Return result
    End Function

    Private Sub loadDanhSachMaHoaNhanVien(ByVal sqlQuery As String)
        Me.DataGridView1.DataSource = moduleDatabaseConn.GetDataTable(sqlQuery)
    End Sub
    Private Sub loadDanhSachLoaiHocVi()
        Dim sqlQuery As String = ""
        sqlQuery = "SELECT ma, ten FROM tbl_loaihocvi ORDER BY ma"
        data1 = moduleDatabaseConn.GetDataTable(sqlQuery)
        CboHocVi.Items.Clear()
        CboHocVi.LoadingType = MTGCComboBox.CaricamentoCombo.DataTable
        CboHocVi.ColumnNum = 2
        CboHocVi.ColumnWidth = "100;250"
        CboHocVi.HighlightBorderColor = Color.Black
        CboHocVi.GridLineHorizontal = True
        CboHocVi.GridLineVertical = True
        CboHocVi.ItemHeight = 17
        CboHocVi.DropDownHeight = 300
        CboHocVi.SourceDataTable = data1
        CboHocVi.SelectedIndex = 0
    End Sub
    Private Sub CboLoaiHocVi_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles CboHocVi.SelectedIndexChanged
        Me.TxtTenHocVi.Text = Me.CboHocVi.SelectedItem.Col2
        If Me.stateCapNhatThanh = True Then
            loadKeyCapNhat()
        Else
            loadKey()
        End If
    End Sub
    Private Sub loadDanhSachTenNhanVien1()
        Dim sqlQuery As String = ""
        sqlQuery = "SELECT ma_nhacungcap,ten_nhacungcap FROM tbl_nhanvien ORDER BY ma_nhacungcap"
        data2 = moduleDatabaseConn.GetDataTable(sqlQuery)
        CboTenNhanVien.Items.Clear()
        CboTenNhanVien.LoadingType = MTGCComboBox.CaricamentoCombo.DataTable
        CboTenNhanVien.ColumnNum = 2
        CboTenNhanVien.ColumnWidth = "100;250"
        CboTenNhanVien.HighlightBorderColor = Color.Black
        CboTenNhanVien.GridLineHorizontal = True
        CboTenNhanVien.GridLineVertical = True
        CboTenNhanVien.ItemHeight = 17
        CboTenNhanVien.DropDownHeight = 300
        CboTenNhanVien.SourceDataTable = data2
        CboTenNhanVien.SelectedIndex = 0
    End Sub
    Private Sub CboTenNhanVien_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles CboTenNhanVien.SelectedIndexChanged
        Me.TxtTenNhanVien.Text = Me.CboTenNhanVien.SelectedItem.Col2
        If Me.stateCapNhatThanh = True Then
            loadKeyCapNhat()
        Else
            loadKey()
        End If
    End Sub
    Private Sub loadDanhSachLoaiNganhNghe()
        Dim sqlQuery As String = ""
        sqlQuery = "SELECT ma,ten FROM tbl_loainganhnghe ORDER BY ma"
        data3 = moduleDatabaseConn.GetDataTable(sqlQuery)
        CboNganhNghe.Items.Clear()
        CboNganhNghe.LoadingType = MTGCComboBox.CaricamentoCombo.DataTable
        CboNganhNghe.ColumnNum = 2
        CboNganhNghe.ColumnWidth = "100;250"
        CboNganhNghe.HighlightBorderColor = Color.Black
        CboNganhNghe.GridLineHorizontal = True
        CboNganhNghe.GridLineVertical = True
        CboNganhNghe.ItemHeight = 17
        CboNganhNghe.DropDownHeight = 300
        CboNganhNghe.SourceDataTable = data3
        CboNganhNghe.SelectedIndex = 0
    End Sub
    Private Sub CboNganhNghe_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles CboNganhNghe.SelectedIndexChanged
        Me.TxtTenNganhNghe.Text = Me.CboNganhNghe.SelectedItem.Col2
        If Me.stateCapNhatThanh = True Then
            loadKeyCapNhat()
        Else
            loadKey()
        End If
    End Sub
    Private Sub DataGridView1_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick
        Me.stateCapNhatThanh = True
        Dim iRow As Integer = Me.DataGridView1.CurrentRow.Index
        Me.txtMaNhanVien.Text = Me.DataGridView1.Item(0, iRow).Value
        loadMa(Me.DataGridView1.Item(0, iRow).Value)
    End Sub

    Private Sub BtnIn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnIn.Click
        FrmCrMaHoaNhanVien.Show()
    End Sub

    Private Sub loadKey()
        Dim key As String = ""
        Dim gt As String = ""
        If Me.OptNam.Checked Then
            gt = "M"
        Else
            gt = "F"
        End If
        key = Me.TxtKyHieu.Text.ToUpper + gt + Me.CboTenNhanVien.Text.ToUpper + Me.CboHocVi.Text.ToUpper + Me.CboNganhNghe.Text.ToUpper
        If Me.stateTaoMoi = True Then
            Me.txtMaNhanVien.Text = key
        Else
            Me.txtMaNhanVien.Text = ""
        End If
        Me.txtCapNhatThanh.ReadOnly = True
        Me.txtMaNhanVien.ReadOnly = True
    End Sub

    Private Sub loadKeyCapNhat()
        Dim key As String = ""
        Dim gt As String = ""
        If Me.OptNam.Checked Then
            gt = "M"
        Else
            gt = "F"
        End If
        key = Me.TxtKyHieu.Text.ToUpper + gt + Me.CboTenNhanVien.Text.ToUpper + Me.CboHocVi.Text.ToUpper + Me.CboNganhNghe.Text.ToUpper
        If Me.stateCapNhatThanh = True Then
            Me.txtCapNhatThanh.Text = key
        Else
            Me.txtCapNhatThanh.Text = ""
        End If
        Me.txtCapNhatThanh.ReadOnly = True
        Me.txtMaNhanVien.ReadOnly = True
    End Sub
    Private Sub OptNam_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OptNam.CheckedChanged
        If Me.stateCapNhatThanh = True Then
            loadKeyCapNhat()
        Else
            loadKey()
        End If
    End Sub

    Private Sub OptNu_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OptNu.CheckedChanged
        If Me.stateCapNhatThanh = True Then
            loadKeyCapNhat()
        Else
            loadKey()
        End If
    End Sub
End Class


